<template>
  <div>
    <el-dialog
      v-dialogDrag
      append-to-body
      :close-on-click-modal="false"
      :before-close="crud.cancelCU"
      :visible="crud.status.cu > 0"
      :title="crud.status.title"
      width="500px"
    >
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        size="small"
        label-width="80px"
      >
        <el-form-item
          label="学期"
          prop="session"
        >
          <el-input
            v-model="form.session"
            style="width: 370px;"
            placeholder="输入学期名称"
          />
        </el-form-item>
        <el-form-item
          label="开始时间"
          prop="begin_date"
        >
          <el-date-picker
            v-model="form.begin_date"
            type="date"
            placeholder="选择开始日期"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
          />
        </el-form-item>
        <el-form-item
          label="结束时间"
          prop="end_date"
        >
          <el-date-picker
            v-model="form.end_date"
            type="date"
            placeholder="选择结束日期"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
          />
        </el-form-item>
        <el-form-item
          label="周数"
          prop="weeksum"
        >
          <el-input-number v-model="form.weeksum" :disabled="false" />
        </el-form-item>
      </el-form>
      <div
        slot="footer"
        class="dialog-footer"
      >
        <el-button
          type="text"
          @click="crud.cancelCU"
        >
          取消
        </el-button>
        <el-button
          :loading="crud.status.cu === 2"
          type="primary"
          @click="crud.submitCU"
        >
          确认
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { form } from '@crud/crud'
const defaultForm = {
  id: null,
  weeksum: 0
}
export default {
  mixins: [form(defaultForm)],
  props: {
  },
  data() {
    return {
      rules: {
        session: [
          { required: true, message: '请输入计划名称', trigger: 'blur' }
        ],
        begin_date: [
          { required: true, message: '请选择开始日期', trigger: 'blur' }
        ],
        end_date: [
          { required: true, message: '请选择结束日期', trigger: 'blur' }
        ],
        weeksum: [
          { required: true, message: '请输入周数', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {

  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  /deep/ .el-input-number .el-input__inner {
    text-align: left;
  }
</style>
